package com.hspedu.enum_;

/*
 *@auther will
 *@version 1.0
 */public class EnumMethod {
    public static void main(String[] args) {
        Season2 autumn = Season2.AUTUMN;
        //输出枚举类对象的名字
        System.out.println(autumn.name());
        //ordinal() 输出的是该枚举对象的次序/编号，从0开始编号
        //AUTUMN 枚举对象是第三个，因此输出 2
        System.out.println(autumn.ordinal());
        //含有定义的所有枚举对象
        Season2[] values = Season2.values();
        for (Season2 season:values) {//增强for 循环
            System.out.println(season);
        }

        //根据你输入的"AUTUMN"到Season2的枚举对象去查找
        //如果找到了，就返回，如果没有找到，就报错
        Season2 autumn1 = Season2.valueOf("AUTUMN");
        System.out.println(autumn1);
        System.out.println(autumn==autumn1);

        //compareTo:比较两个枚举类，比较的就是编号
        //就是把Season2.AUTUMN 枚举对象的编号 和 Season2.SUMMER枚举对象的编号比较
        //就是把Season2.AUTUMN的编号 减去 Season2.SUMMER的编号
        System.out.println(Season2.AUTUMN.compareTo(Season2.SUMMER));
    }
}
